package cn.dlc.com.order.config;

import com.alibaba.csp.sentinel.adapter.servlet.callback.RequestOriginParser;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 邓立川
 * @date 2020/12/31 15:31
 * @desc 规则为授权的时候配置使用的类，这个没事最好关掉，否则其他方法也会要传递这个参数
 */
//@Component
public class RequestOriginParserDefinition implements RequestOriginParser {

    @Override
    public String parseOrigin(HttpServletRequest request) {
        String serviceName = request.getParameter("serviceName");
        if(StringUtils.isBlank(serviceName)) {
            throw new RuntimeException("serviceName is empty");
        }
        return serviceName;
    }
}